package org.leo.model.connector;

public enum ConnectType {
    MYSQL(
        "com.mysql.cj.jdbc.Driver",
        "jdbc:mysql://{host}:{port}/{database}",
        "MySQL Connector/J"
    ),
    POSTGRESQL(
        "org.postgresql.Driver",
        "jdbc:postgresql://{host}:{port}/{database}",
        "PostgreSQL JDBC Driver"
    ),
    ORACLE(
        "oracle.jdbc.OracleDriver",
        "jdbc:oracle:thin:@{host}:{port}:{database}",
        "Oracle JDBC Driver"
    ),
    SQLSERVER(
        "com.microsoft.sqlserver.jdbc.SQLServerDriver",
        "jdbc:sqlserver://{host}:{port};databaseName={database}",
        "Microsoft JDBC Driver"
    ),
  ;

    private final String driverClass;
    private final String urlTemplate;
    private final String displayName;

   ConnectType(String driverClass, String urlTemplate, String displayName) {
        this.driverClass = driverClass;
        this.urlTemplate = urlTemplate;
        this.displayName = displayName;
    }

    // Getters
    public String getDriverClass() {
       
        return driverClass;
    }

    public String buildUrl(String host, int port, String database) {
        System.out.println("Building URL for " + this.displayName);
        System.out.println(this.urlTemplate);
        return urlTemplate
                .replace("{host}", host)
                .replace("{port}", String.valueOf(port))
                .replace("{database}", database);
    }
}